
<link rel="stylesheet" href="jquery/easyui/themes/default/easyui.css">
<link rel="stylesheet" href="jquery/easyui/themes/icon.css">
<body>
<div style="width: 100%;height: 87%">
    <table id="easyui_datagrid_data_basic_set" style="border:1px solid blue" >

    </table>
</div>

<div id="dlg" class="easyui-dialog" style="width:400px" closed="true" buttons="#dlg-buttons">
    <form id="fm" method="post" novalidate style="margin:0;padding:20px 50px">
<!--
        <div style="margin-bottom:20px;font-size:14px;border-bottom:1px solid #ccc">User Information</div>
-->
        <div style="margin-bottom:10px">
            <select class="easyui-combobox" name="html_type" required label="类型" style="width:100%">
                <option value="">请选择</option>
                <option value="select">下拉框</option>
            </select>

        </div>
        <div style="margin-bottom:10px">
            <input name="html_type_val" class="easyui-textbox" label="参数:" style="width:100%">
        </div>
    </form>
</div>
<div id="dlg-buttons">
    <a href="javascript:void(0)" class="easyui-linkbutton c6" iconCls="icon-ok" onclick="saveUser()" style="width:90px">Save</a>
    <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-cancel" onclick="javascript:$('#dlg').dialog('close')" style="width:90px">Cancel</a>
</div>


<script src="https://upload.shinehao.com.cn/20180816150739jquery-1.8.3.min.js"></script>
<script src="https://upload.shinehao.com.cn/20180816145716jquery.easyui.min.js"></script>
<script src="https://upload.shinehao.com.cn/20180816151727easyui-lang-zh_CN.js"></script>
<script src="jquery/easyui/ext/extBrowser.js"></script>
<script src="jquery/easyui/ext/extEasyui.js"></script>
<script src="jquery/easyui/ext/extJquery.js"></script>
<script>

var cpLock = false;
$(function(){
    /*$("body").bind("click",function(){
        $('#easyui_datagrid_data_basic_set').combogrid("showPanel");
    })*/
    $('#easyui_datagrid_data_basic_set').combogrid({
        mode:"remote",
        url:window.parent.serverUrl+"/createOrder/getDataBasicList",
        queryParams: {
            
        },
        idField: 'id',
        textField: 'text',
        columns:[[
            {field:'t',width:100,title:'操作',formatter(value, rowData, rowIndex){
                /*var str1 = $.formatString('<img style="cursor:pointer" iconCls="icon-add" onclick="updateData(\'{0}\');" title="编辑"  src="{1}"/>',rowData,'jquery/easyui/themes/icons/pencil.png');
                return str1;*/
               return '<a href="javascript:updateData()" class="easyui-linkbutton" iconCls="icon-add" plain="true">编辑</a>';
            }},
            {field:'id',title:'id'},
            {field:'text',title:'名称',align:"center"},
            {field:'html_type',title:'类型',align:"center",formatter:function(value){
                if("select"==value){
                    return "下拉框";
                }    
            }
            },
            {field:'html_type_val',title:'参数',align:"center"},
        ]],
        height:"10%",
        width:"80%",
        panelWidth:"100%",
        panelHeight:"88%",
        //rownumbers:true,
        //fitColumns:true,
        pagination:false,
        loadMsg:"加载中,请等待...",
        singleSelect:true,
        align:"center",
        //toolbar: '#easyui_datagrid_source_fac_tool',
        loadFilter: function(data){
          return data.data;  
        },
        keyHandler: {
            enter: function(e){
            },
            query: function (q) {
            	setTimeout(function(){
	            	if(!cpLock){
	            		$('#easyui_datagrid_data_basic_set').combogrid("grid").datagrid("reload", {
	                        'q': q,
	                    });
	                    $('#easyui_datagrid_data_basic_set').combogrid("setValue",q);
	            	}
            	},0);
            },
            up: function (e) {
                
            },
            down: function (e) {
                
            }
        },
        onLoadSuccess:function(data){
            if(data.total > 0) {
                $("input[type='text']").focus();
                return;
            }  
            //$(this).datagrid('appendRow', { color: '<div style="text-align:center;color:red">没有相关记录！</div>' }).datagrid('mergeCells', { index: 0, field: 'color', colspan: 3});  
            $("input[type='text']").focus();
            $('#easyui_datagrid_data_basic_set').combogrid("showPanel");
            $("input[type='text']").on('compositionstart', function () {
                cpLock = true;
            });
            $("input[type='text']").on('compositionend', function () {
                cpLock = false;
            });
        },
        onClickRow:function(index,row){
            $("input[type='text']").focus();
            $('#easyui_datagrid_data_basic_set').combogrid("showPanel");
        }
    });
    $('#easyui_datagrid_data_basic_set').combogrid("showPanel");
    $("input[type='text']").focus();
    
    $("#dlg").dialog({  
        onClose: function () {  
            $('#easyui_datagrid_data_basic_set').combogrid("showPanel"); 
        }  
    });  
})

var url;
function updateData(data){
    $('#easyui_datagrid_data_basic_set').combogrid("hidePanel");
    var row = $('#easyui_datagrid_data_basic_set').combogrid('grid').datagrid('getSelected');
    if (row){
        $('#dlg').dialog('open').dialog('center').dialog('setTitle','编辑'+row.text);
        $('#fm').form('clear');
        $('#fm').form('load',row);
        url = window.parent.serverUrl+"/createOrder/updateDataBasicById?id="+row.id;
    }
}
function saveUser(){
    $.messager.progress();
    $('#fm').form('submit',{
        url: url,
        onSubmit: function(){
            return $(this).form('validate');
        },
        success: function(result){
            $.messager.progress('close');
            alert("操作成功");
            $('#dlg').dialog('close');        // close the dialog
            $('#easyui_datagrid_data_basic_set').combogrid("grid").datagrid("reload");
            $('#easyui_datagrid_data_basic_set').combogrid("showPanel");
            $("input[type='text']").focus();
            /*var result = eval('('+result+')');
            if (result.errorMsg){
                $.messager.show({
                    title: 'Error',
                    msg: result.errorMsg
                });
            } else {
                $('#dlg').dialog('close');        // close the dialog
                $('#easyui_datagrid_data_basic_set').datagrid('reload');    // reload the user data
            }*/
        }
    });
}
</script>
</body>


























